package pl.nazaweb.imedproplus.model.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import pl.nazaweb.imedproplus.model.interfaces.IDiagnosis;

@Entity
@Table(name = "diagnosis")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Diagnosis.findAll", query = "SELECT d FROM Diagnosis d"),
    @NamedQuery(name = "Diagnosis.findById", query = "SELECT d FROM Diagnosis d WHERE d.id = :id")})
public class Diagnosis implements Serializable, IDiagnosis {

    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "diagnosis_sequence_", sequenceName = "diagnosis_sequence", allocationSize=1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "diagnosis_sequence_")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Long id;
    @JoinColumn(name = "visit", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Visit visit;
    @JoinColumn(name = "icd10", referencedColumnName = "code")
    @ManyToOne(optional = false)
    private Icd10 icd10;

    public Diagnosis() {
    }

    public Diagnosis(Long id) {
        this.id = id;
    }

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public Visit getVisit() {
        return visit;
    }

    @Override
    public void setVisit(Visit visit) {
        this.visit = visit;
    }

    @Override
    public Icd10 getIcd10() {
        return icd10;
    }

    @Override
    public void setIcd10(Icd10 icd10) {
        this.icd10 = icd10;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Diagnosis)) {
            return false;
        }
        Diagnosis other = (Diagnosis) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.nazaweb.imedproplus.model.entity.Diagnosis[ id=" + id + " ]";
    }
}
